 <!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title>注册</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/user/css/cloud-admin.css" >
	
	<link href="__PUBLIC__/static/user/css/font-awesome.min.css" rel="stylesheet">
	<!-- DATE RANGE PICKER -->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/user/css/daterangepicker-bs3.css" />
	<!-- UNIFORM -->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/user/css/uniform.default.min.css" />
	<!-- ANIMATE -->
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/user/css/animate.min.css" />
	</head>
 <div class="container">
<body class="login">	
	<!-- PAGE -->
	<section id="page">
			<!-- HEADER -->
			<header>
				<!-- NAV-BAR -->
				<div class="container">
					<div class="row">
						<div class="col-md-4 col-md-offset-4">
							
						</div>
					</div>
				</div>
				<!--/NAV-BAR -->
			</header>
			<!--/HEADER -->
			<!-- LOGIN -->
			<!--<section id="login_bg" class="visible">
				<div class="container">
					<div class="row">
						<div class="col-md-4 col-md-offset-4">
							<div class="login-box">
								<h2 class="bigintro"></h2>
								<div class="divide-40"></div>
								<form role="form" action="{:url('Index/login')}" method="post">
								  <div class="form-group">
									<label>帐号</label>
									<i class="fa fa-envelope"></i>
									<input type="text" id="account" class="form-control"  onchange="check('account')" required="" name="user_account" maxlength="10" >
								  </div>
								  <div class="form-group"> 
									<label>密码</label>
									<i class="fa fa-lock"></i>
									<input type="password" id="pwd" onchange="check('pwd')" class="form-control" required="" name="user_password" maxlength="50">
								  </div>
								  
								  <div>
									<label class="checkbox"> <input type="checkbox" class="uniform" value=""> 记住密码</label>
									<button type="submit"  class="btn btn-danger">登录</button>
								  </div>
								</form>

								<div class="login-helpers">
									<a href="#" onclick="swapScreen('register_bg');return false;">注册</a>
								</div>
								
							</div>
						</div>
					</div>
				</div>
			</section>-->
			<!--/LOGIN -->
			<!-- REGISTER -->
			<section id="register_bg" class="visible">
				<div class="container">
					<div class="row">
						<div class="col-md-4 col-md-offset-4">
							<div class="login-box">
								<h2 class="bigintro">注册账号</h2>
								<div class="divide-40"></div>
								<form method="post" action="">
								  <div class="form-group">
									<label>手机号（即账号）</label>
									<i class="fa fa-font"></i>
									<input type="text" id="accountr" class="form-control" placeholder="请输入手机号码" required="" name="user_account" maxlength="11" >
								  </div>
								  <div class="form-group">
									<label>昵称</label>
									<i class="fa fa-user"></i>
									<input id="nickname" type="text" class="form-control" placeholder="最多20个字符" required="" name="user_name" maxlength="20" >
								  </div>
								  <div class="form-group">
									<label>个人签名</label>
									<i class="fa fa-edit"></i>
									<input id="motto" type="text" class="form-control" placeholder="最多30个字符" required="" name="motto" maxlength="30" >
								  </div>
								  <div class="form-group"> 
									<label>密码</label>
									<i class="fa fa-lock"></i>
									<input type="password" class="form-control" placeholder="6-15位大小写英文字母、数字或符号的组合" required="" id="pwdr" name="user_password" maxlength="15">
								  </div>
								  <div class="form-group"> 
									<label>确认密码</label>
									<i class="fa fa-lock"></i>
									<input type="password" class="form-control" placeholder="请再次输入密码" required="" id="pwdr2" name="user_password2" maxlength="40">
								  </div>
								  <div>
								  	<input type="button" onclick="check()" class="btn" value="注册"></input>
									<!--<button onclick="check()" class="btn btn-success">注册</button>-->
								  </div>
								</form>
								<!-- SOCIAL REGISTER -->
								
								<!-- /SOCIAL REGISTER -->
								<div class="login-helpers">
									<a href="index">返回登录</a> <br>
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>
			<!--/REGISTER -->
			<!-- FORGOT PASSWORD -->
		
			<!-- FORGOT PASSWORD -->
	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="__PUBLIC__/static/user/js/jquery-2.0.3.min.js"></script>
	<script src="__PUBLIC__/static/user/js/jquery.backstretch.min.js"></script>
	<script src="__PUBLIC__/static/user/js/jquery.cookie.js"></script>
	<!-- JQUERY UI-->
	<script src="__PUBLIC__/static/user/js/jquery-ui-1.10.3.custom.min.js"></script>
	<!-- BOOTSTRAP -->
	<script src="__PUBLIC__/static/bootstrap/js/bootstrap.min.js"></script>
	
	<script src="__PUBLIC__/static/bootstrap/js/md5.js"></script>
	<!-- UNIFORM -->
	<script type="text/javascript" src="__PUBLIC__/static/user/js/jquery.uniform.min.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="__PUBLIC__/static/user/js/script.js"></script>
	<script>
		jQuery(document).ready(function() {		
			App.setPage("login_bg");  //Set current page
			App.init(); //Initialise plugins and elements
		});
	</script>
	<script type="text/javascript">
		function swapScreen(id) {
			jQuery('.visible').removeClass('visible animated fadeInUp');
			jQuery('#'+id).addClass('visible animated fadeInUp');
		}
	</script>
	<script type="text/javascript">
		function check(){
			var phone =document.getElementById('accountr').value;
			var nickname=document.getElementById('nickname').value;
			var motto=document.getElementById('motto').value;
			var pwdr=document.getElementById('pwdr').value;
			var pwdr2=document.getElementById('pwdr2').value;
			var message="";
			if(phone==""||phone==null){
				message+="手机号不能为空！\n";
			}
			else if(!(/^1[3|4|5|6|7|8][0-9]\d{4,8}$/.test(phone))){
				message+="手机号格式不正确！\n";
			}
			if(nickname==null||nickname==""){
				message+="昵称不能为空！\n";
			}
			else if(nickname.length>20){
				message+="昵称长度不能超过20个字符！\n";
			}
			if(motto==""||motto==null){
				message+="个人签名不能为空！\n";
			}
			else if(motto.length>30){
				message+="个人签名长度不能超过30个字符！\n";
			}
			if(pwdr==""||pwdr2==""||pwdr==null||pwdr2==null){
				message+="密码不能为空！\n";
			}
			else if(pwdr.length<6||pwdr2.length<6){
				message+="密码至少为6位\n";
			}
			else if(pwdr!=pwdr2){
				message+="两次密码输入不一致！\n";
			}
			if(message!="")
				alert(message);
			else{
				$.ajax({
					type:"post",
					url:"register",
					cache: false,
					async:true,
					data: {
							'accountr':$("#accountr").val(),
							'nickname':$("#nickname").val(),
							'motto':$("#motto").val(),
							'pwdr': hex_md5($("#pwdr").val()),
							'pwdr2': hex_md5($("#pwdr2").val())
						},
						success: function(data) {
							if(data == "1") {
								alert("注册成功！");
								window.location.href = "index";
							} 
							else if(data == "2"){
								alert("该手机号已被注册！");
							}
							else if(data=="3") {
								alert("该昵称已被注册！");
							}
							else{
								alert("出现错误！");
							}
						},
						error: function() {
							alert("服务器出错了");
						}
				});
			}
//          var x=document.getElementById(str);
//          if(str=='account'||str=='accountr'){
//          	var len=x.value.length;
//          	if(len<'9'||(/[\u4e00-\u9fa5]+/).test(x.value)){
//          		alert('账号格式不正确');
//          		x.value="";
//          	}
//          }
//          else if(str=='pwd'||str=='pwdr'){
//          	var len=x.value.length;
//          	if(len<'6'){
//          		alert('密码至少为6位');
//          		x.value="";
//          	}
//          }
		}
	</script>
	<!-- /JAVASCRIPTS -->
</body>
</html>